package nowcoder.day_48.day15;
//OR57 手套
public class Num2 {
    public static void main(String[] args) {

    }
    public int findMinimum(int n, int[] left, int[] right) {
        int sum = 0;
        int leftMin = Integer.MAX_VALUE;
        int rightMin = Integer.MAX_VALUE;
        int leftSum = 0;
        int rightSum = 0;
        for (int i = 0; i < n; i++) {
            if (left[i] * right[i] == 0){
                sum = sum + left[i] + right[i];
            }else {
                leftSum += left[i];
                if (leftMin > left[i]){
                    leftMin = left[i];
                }
                rightSum += right[i];
                if (rightMin > right[i]){
                    rightMin = right[i];
                }
            }
        }
        return Math.min(leftSum - leftMin + 1 , rightSum - rightMin + 1) + sum + 1;
    }
}
